﻿using System;

namespace 三月三贰
{
    class Program
    {
        static void Main(string[] args)
       
        {
            // 11.用户输入整数n，计算1! + (1! + 2!) + (1! + 2! + 3!) +…..+(1! + 2! +…n!)
            Console.WriteLine("请输入整数N");
            int N = Convert.ToInt32(Console .ReadLine ());
            wayOne(N );
            wayTwo(N);
            wayThree(N);
            Console.WriteLine("1! + (1! + 2!) + (1! + 2! + 3!) +…..+(1! + 2! +…n!)={0}",wayThree(N));
            static int wayOne(int N)
            {
                int sum = 1;
                for (int i=1;i<=N ;i++) {
                    sum*= i;
                }
                return sum;
            }
            static int wayTwo(int N)
            {
                int sam = 0;
                for (int i=1;i<=N;i++) {
                    sam += wayOne(i);
                }
                return sam;
            }
            static int wayThree(int N)
            {
                int scm = 0;
                for (int i = 1; i <= N; i++)
                {
                    scm += wayTwo(i);
                }
                return scm;
            }
        }
    }
}
